package state;

/**
 * 上下文信息对象，存储了一个currentState当前状态对象，可通过方法进行更新
 */
public class Context {
    private State currentState;

    public Context(State currentState) {
        this.currentState = currentState;
        if (this.currentState == null){
            this.currentState = StateA.instance();
        }
    }

    public State getCurrentState() {
        return currentState;
    }

    public void setCurrentState(State currentState) {
        this.currentState = currentState;
    }

    public void update(){
        currentState.updateState(this);
    }
}
